package com.spring.soundsystem;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

//如果不想使用spring自带注解 可以使用@Inject和@Named
@Component
public class CDPlayer implements MediaPlayer {
    private CompactDisc cd;

    @Autowired
    public CDPlayer(CompactDisc cd){
        this.cd = cd;
    }
    public void play(){
        cd.play();
    }
    @Autowired
    public void setCd(CompactDisc cd) {
        this.cd = cd;
    }
}
